using System.Collections.Generic;
using System.ComponentModel;
using OpenFlashChartLib.Json;

namespace OpenFlashChartLib.Charts
{
    public class XAxis : Axis
    {
        private XLabelsCollection labels;
        private bool _offset = true;

        [JsonProperty("offset")]
        [DefaultValue(true)]
        public bool Offset 
        {
            get { return _offset; }
            set { _offset = value; }
        }

        [JsonProperty("labels")]
        public XLabelsCollection Labels
        {
            get
            {
                if (labels == null)
                    labels = new XLabelsCollection();
                return labels;
            }
            set { labels = value; }
        }

        [JsonProperty("tick-height")]
        public string TickHeight { get; set; }

        public void SetRange(double min, double max)
        {
            Max = max;
            Min = min;
        }

        public bool HasLabelsChanged()
        {
            return labels != null && labels.Labels.Count > 0;
        }

        public override bool IsSpecified()
        {
            return !string.IsNullOrEmpty(TickHeight) || Offset == false || 
                HasLabelsChanged() || base.IsSpecified();
        }
    }
}